package com.archives.blog.common.domain.entity;

import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.Table;

import com.archives.blog.common.domain.pojo.request.ArticleChannelAddRequest;
import com.archives.blog.common.domain.pojo.request.ArticleChannelModifyRequest;
import com.archives.blog.common.support.BaseEntity;

/**
 * 文章频道/分类
 * 
 * @author chh
 *
 */
@Entity
@Table(name = "blog_article_channel")
public class ArticleChannel extends BaseEntity<Long>{

	private String name;
	
	private Long parentId;

	public void create(ArticleChannelAddRequest request){
		this.setCreater(request.getOperator());
		this.setModifier(request.getOperator());
		this.setGmtCreate(new Date());
		this.setGmtModifyed(new Date());
		this.setParentId(request.getParentId());
		this.setName(request.getName());
	}
	
	public void modify(ArticleChannelModifyRequest request){
		this.setCreater(request.getOperator());
		this.setModifier(request.getOperator());
		this.setGmtCreate(new Date());
		this.setGmtModifyed(new Date());
		this.setParentId(request.getParentId());
		this.setName(request.getName());
		this.setId(request.getChannelId());
	}
	
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the parentId
	 */
	public Long getParentId() {
		return parentId;
	}

	/**
	 * @param parentId the parentId to set
	 */
	public void setParentId(Long parentId) {
		this.parentId = parentId;
	}
	
}
